package com.SFA.Main;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.SFA.R;

public class ImageTextButton extends LinearLayout
{

	private ImageView    button = null;
	private TextView     text   = null;
	private Context      context;

	private LinearLayout layout;

	public ImageTextButton(Context context)
	{
		this(context, null);
		this.context = context;
	}

	public ImageTextButton(Context context, AttributeSet attrs)
	{
		super(context, attrs);
		layout = (LinearLayout) LayoutInflater.from(context)
		.inflate(R.layout.imagetextbutton,
				this,
				true);
		button = (ImageView) this.findViewById(R.id.button);
		text = (TextView) this.findViewById(R.id.btnText);
		text.setSingleLine(true);
	}

	

	public void setImageBitmap(Bitmap bitmap)
	{
		if (button != null)
			button.setImageBitmap(bitmap);
	}

	public void setBackground(int id)
	{
		layout.setBackgroundResource(id);
	}

	public void setBackgroundDrawable(Drawable drawable, int Width, int Hdight)
	{
		if (button != null)
		{
			button.setBackgroundDrawable(drawable);
			button.setMinimumHeight(Hdight);
			button.setMinimumWidth(Width);
		}

	}

	public void setText(String title)
	{
		if (text != null)
			text.setText(title);
	}

	public void setText(int ResID)
	{
		if (text != null)
			text.setText(ResID);
	}

	public void setWidth(int width)
	{
		button.setMaxWidth(width);
	}

	public void setHeight(int height)
	{
		button.setMaxHeight(height);
	}

}
